package utils

import (
	"encoding/json"
	"github.com/astaxie/beego/cache"
	_ "github.com/astaxie/beego/cache/redis"
	_ "github.com/garyburd/redigo/redis"
	_ "github.com/gomodule/redigo/redis"
)

// 创建新的缓存适配器
func NewCache() (adapter cache.Cache, err error) {
	redisConf := map[string]string{
		"key":   GServerName,
		"conn":  GRedisAddr + ":" + GRedisPort,
		"dbNum": GRedisDbnum,
	}
	redisConfJson, _ := json.Marshal(redisConf)

	return cache.NewCache("redis", string(redisConfJson))
}
